#pragma once
#include "ModBus/ModBusDefine.h"
#include "SyncQueue.h"
#include <atomic>
#include <map>
#include <queue>
class Publisher_profile;
class Subscriber_profile;
class Message;
class ModBusProcess
{
private:
    /* data */
public:
    ModBusProcess(/* args */);
    ~ModBusProcess();

    void update(const MODBUS::CollectData& data);

    void init();
    void start();
    void stop();

    void onPublish(Message);
    void Int2Byte(int, std::vector<uint8_t> &);
    void Double2Byte(double, std::vector<uint8_t>&);
    
private:
    void process();
    void startTimer();
    
private:
    SyncQueue<MODBUS::CollectData> *mDataQueue;
    std::atomic<bool> mQuit;
    Publisher_profile *pub;
    Subscriber_profile *sub;

    std::map<int, std::queue<double>> mData;
    std::mutex data_mutex;
};
